package com.nkzy.servlet; /**
 * Create by 王建烨 on 2022/4/1 11:11
 **/


import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * SpringBoot集成Servlet
 *
 * 原理：创建一个配置类，在配置类通过@Bean让框架实例化
 *
 * 步骤一：
 */

public class SecondServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 把Get交给Post处理
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setHeader("content-type","text/html;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.getWriter().println("<h1>嗨害嗨！Second Servlet</h1>");
        System.out.println("嗨害嗨！Second Servlet");
    }
}
